#include "oled.h"
#include "stdio.h"
#include "bsp_weather.h"

void Weather_Display(struct weatherStruct structWeatherData){
	char weather_str[50];
	char temperature_str[50];
	uint8_t chr[] = "sprintf error!";

	int f1 = sprintf(weather_str, "%s", structWeatherData.weather);
	int f2 = sprintf(temperature_str, "T:%s", structWeatherData.temperature);
	if(f1 < 0 || f2 < 0){
		OLED_Clearrow(weather_y);
		OLED_ShowString(weather_x, weather_y, chr, sizeof(chr));
	}
	else{
		/* display */
		OLED_Clearrow(weather_y);
		OLED_ShowString(weather_x, weather_y, (uint8_t*) weather_str, sizeof(weather_str));
		OLED_ShowString(temperature_x, weather_y, (uint8_t*) temperature_str, sizeof(temperature_str));
	}
}
